package hebClustering.vectorSpace.distances;

import hebClustering.vectorSpace.IVector;

/**
 * Implementation of the distance function Chebyshev distance.
 * 
 *	@see <a href="http://en.wikipedia.org/wiki/Chebyshev_distance" target="_blank">Chebyshev distance</a>
 */
public class ChebyshevDistance implements IDistance{

	@Override
	public double calc(IVector v1, IVector v2) {
		double max = 0;
		//int maxI = 0;
		IVector diff = v1.sub(v2);
		
		double abs;
		for(int i : diff){
			abs = Math.abs(diff.ithValue(i));
			if (abs > max){
				//maxI = i;
				max = abs;
			}
		}

//		System.out.printf("Max is reached at %d with word %s\n",maxI,Corpus.getCorpus().getTokenByIndex(maxI));
		return max;
	}

}
